From c669da88e2ae9f0adfab5fc750c966f62577098a Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 30 Nov 2006 17:32:16 +0000 Subject: [PATCH] [QEMU] Simpler workaround for guest writes to PCI config space that extend past byte 0xff. Signed-off-by: Keir Fraser --- tools/ioemu/hw/pci.c | 24 ++++++++---------------- tools/ioemu/vl.h | 7 +++++-- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/tools/ioemu/hw/pci.c b/tools/ioemu/hw/pci.c index cea81f7b7f..77737c8615 100644 --- a/tools/ioemu/hw/pci.c +++ b/tools/ioemu/hw/pci.c @@ -221,24 +221,17 @@ uint32_t pci_default_read_config(PCIDevice *d, uint32_t address, int len) { uint32_t val; - switch(len) { - default: - case 4: - if (address <= 0xfc) { - val = le32_to_cpu(*(uint32_t *)(d->config + address)); - break; - } - /* fall through */ - case 2: - if (address <= 0xfe) { - val = le16_to_cpu(*(uint16_t *)(d->config + address)); - break; - } - /* fall through */ case 1: val = d->config[address]; break; + case 2: + val = le16_to_cpu(*(uint16_t *)(d->config + address)); + break; + default: + case 4: + val = le32_to_cpu(*(uint32_t *)(d->config + address)); + break; } return val; } @@ -340,8 +333,7 @@ void pci_default_write_config(PCIDevice *d, d->config[addr] = val; } - if (++addr > 0xff) - break; + addr++; val >>= 8; } diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index 4ff660c217..3df963241c 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -650,8 +650,11 @@ typedef struct PCIIORegion { #define PCI_MAX_LAT 0x3f /* 8 bits */ struct PCIDevice { - /* PCI config space */ - uint8_t config[256]; + /* + * PCI config space. The 4 extra bytes are a safety buffer for guest + * word/dword writes that can extend past byte 0xff. + */ + uint8_t config[256+4]; /* the following fields are read only */ PCIBus *bus; -- 2.30.2